package com.haoze.nurse.controller;

import com.haoze.common.response.Result;
import com.haoze.common.response.ResultGenerator;
import com.haoze.nurse.model.NurseConsultationGroupEntity;
import com.haoze.nurse.service.ConsultationGroupService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 会诊小组
 *
 * @Author: Chenchao
 * @CreateTime: 2020-12-22 10:34
 */
@RestController
@RequestMapping(value = "/nurse/consultationGroup")
public class ConsultationGroupController {

    @Autowired
    private ConsultationGroupService consultationGroupService;


    @GetMapping("/queryNurse")
    @ApiOperation(value = "查询护士")
    public Result queryNurse(@RequestParam(required = false) String queryString, @RequestParam(required = false) String dataCode, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") int pageSize) {
        List<Map<String, String>> list = consultationGroupService.queryNurse(queryString, dataCode, page, pageSize);
        return ResultGenerator.genOkResult(list);
    }

    @PostMapping("/addGroupNurse")
    @ApiOperation(value = "新增护士至小组")
    public Result addGroupNurse(@RequestBody NurseConsultationGroupEntity entity) {
        return consultationGroupService.addGroupNurse(entity);
    }

    @PostMapping("/updateGroupNurse")
    @ApiOperation(value = "更新护士至小组")
    public Result updateGroupNurse(@RequestBody NurseConsultationGroupEntity entity) {
        return consultationGroupService.updateGroupNurse(entity);
    }

    @GetMapping("/delGroupNurse")
    @ApiOperation(value = "删除护士")
    public Result delGroupNurse(@RequestParam String consultaionGroupId) {
        return consultationGroupService.delGroupNurse(consultaionGroupId);
    }

    @GetMapping("/groupNurseList")
    @ApiOperation(value = "护士小组")
    public Result groupNurseList(@RequestParam(required = false) String queryString, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") int pageSize) {
        return consultationGroupService.groupNurseList(queryString,page,pageSize);
    }

}
